//
//  AppDelegate.m
//  YUNWUMeetingDemo
//
//  Created by mac on 2019/7/11.
//  Copyright © 2019 DGL. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"
#import "MeetingHelper.h"
#import "PathUtil.h"


@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    UINavigationController *rootNavi = [[UINavigationController alloc]initWithRootViewController:[[ViewController alloc]init]];
    
    [self setupConfigure];
    
    self.window.rootViewController = rootNavi;
    self.window.backgroundColor = [UIColor whiteColor];
    
    return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // FIXME:应用退出崩溃 added by king 201803091647
    [[CloudroomVideoSDK shareInstance] uninit];
}
#pragma marl -- method
- (void)setupConfigure{
    [self _setupForStatusBar];
    [self _setupForVideoCallSDK];
//    [self _setupForIQKeyboard];
}

- (void)_setupForStatusBar
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}
- (void)_setupForVideoCallSDK
{
    MeetingHelper *meetingHelper = [MeetingHelper shareInstance];
    [meetingHelper readInfo];
    
    if ([NSString stringCheckEmptyOrNil:meetingHelper.account] ||
        [NSString stringCheckEmptyOrNil:meetingHelper.pswd] ||
        [NSString stringCheckEmptyOrNil:meetingHelper.server]) {
        [meetingHelper resetInfo];
    }
    
    // FIXME:WARNING: QApplication was not created in the main() thread.QObject::connect: No such slot MeetRecordImpl::slot_SetScreenShare(bool)
    SdkInitDat *sdkInitData = [[SdkInitDat alloc] init];
    // TODO:必须指定日志文件路径,才能产生日志文件,并能够上传 added by king 201711061904
    [sdkInitData setSdkDatSavePath:[PathUtil searchPathInCacheDir:@"CloudroomVideoSDK"]];
    //    NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];
    //    [sdkInitData setSdkDatSavePath:docDir];
    [sdkInitData setShowSDKLogConsole:YES];
    [sdkInitData setNoCall:YES];
    [sdkInitData setNoQueue:YES];
    [sdkInitData setNoMediaDatToSvr:NO];
    [sdkInitData setTimeOut:10 * 1000];
    CRVIDEOSDK_ERR_DEF error = [[CloudroomVideoSDK shareInstance] initSDK:sdkInitData];
    
    if (error != CRVIDEOSDK_NOERR) {
        MLog(@"CloudroomVideoSDK init error!");
        [[CloudroomVideoSDK shareInstance] uninit];
    }
    
    MLog(@"GetCloudroomVideoSDKVer:%@", [CloudroomVideoSDK getCloudroomVideoSDKVer]);
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}




@end
